<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <title>微信 JSAPI 支付测试</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <link rel="stylesheet" href="__ROOT__/static/theme/css/mobile.css">
    <style>
        .test-show {
            padding: 10px;
            font-size: 14px;
            margin-top: 10px;
            background: rgba(0, 0, 0, 0.1);
            border-radius: 10px;
        }

        .test-show pre {
            overflow: auto;
            padding: 10px;
        }

        .test-payment {
            padding: 30px 0 10px 0;
            text-align: center
        }

        .test-payment button {
            border: none;
            color: #fff;
            padding: 15px;
            background: #a233c6;
            border-radius: 4px;
        }
    </style>
</head>
<body>
<div style="padding:15px">
    <h3>1. 用户 OPENID</h3>
    <div class="test-show">
        <pre>{$user['openid']}</pre>
    </div>
    <br>
    <h3>2. 微信 JSAPI 支付参数</h3>
    <div class="test-show">
        <pre>{:json_encode($result,64|128|256)}</pre>
    </div>
    <div class="test-payment">
        <button id='paytest' type='button'>发起 JSAPI 支付 0.01 元</button>
    </div>
</div>

<script src='//res.wx.qq.com/open/js/jweixin-1.6.0.js'></script>
<script>
    wx.config(JSON.parse('{$configJson|raw}'));
    document.getElementById('paytest').onclick = function () {
        let options = JSON.parse('{$optionJson|raw}');
        options.success = function () {
            alert('支付成功');
        };
        console.log("OPTIONS:", options);
        wx.chooseWXPay(options);
    }
</script>
</body>
</html>